var app =getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    language:"",
    flag_status: true,
    goods:[],
    goods_template:{},
    album:{},
    album_id:'',
    list:[],
    last_page:1,
    current_page:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.scene) {
      let scene = decodeURIComponent(options.scene);
      if (scene) {
        var info_arr = [];
        info_arr = scene.split(",");
        for (let i = 0; i < info_arr.length; i++) {
          let chil_arr = [];
          chil_arr = info_arr[i].split("=");
          if (chil_arr[0] == "album_id") {
            // chil_arr[1] album_id
            this.setData({album_id:chil_arr[1]})
          }
        }
      }
    }
    if(options.album_id) {
      this.data.album_id = Number(options.album_id);
    }
    this.getData(this.data.album_id)
  },
  gotoGood(e) {
    wx.navigateTo({
      url: "/packageA/detail_v2/detail_v2?id=" + e.currentTarget.dataset.id,
    });
  },
  handle(e){
    // var query = wx.createSelectorQuery();
    // console.log(query.select(".describe-content"))
    this.setData({flag_status:!this.data.flag_status});
  },
  getData(album_id) {
    app._getNetWork({
      url: app.getNetAddresss("plugin.yz-supply.frontend.album.detail.index"),
      data:{page:1, album_id},
      success:res=>{
        if(res.data.result){
          this.setData({
            album:res.data.data.album,
            list:res.data.data.list.data,
            last_page:res.data.data.list.last_page
          })
        }
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    let language = wx.getStorageSync('langIndex');
    this.setData({ 'language': language.en });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    if(this.data.current_page>=this.data.last_page){
      return;
    }
    let page = this.data.current_page+1;
    app._getNetWork({
      url: app.getNetAddresss("plugin.yz-supply.frontend.album.detail.index"),
      data:{page, album_id:this.data.album_id},
      success:res=>{
        if(res.data.result){
          this.setData({
            list:this.data.list.concat(res.data.data.list.data),
            current_page:res.data.data.list.current_page
          })
        }
      }
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})